def check(x):
if(''.join(sorted(x))==x):
return 1
return 0
for i in range(int(input())):
n = int(input())
x = input()
if(x.isnumeric()):
if(check(x)):
print("YES")
else:
print("NO")
elif(x.isalpha()):
if(check(x)):
print("YES")
else:
print("NO")
else:
alpha = ""
nums = ""
change = 0
for i in range(n):
if(x[i].isnumeric()):
if(change==1):
print("NO")
break
nums+=x[i]
if(x[i].isalpha()):
change=1
alpha+=x[i]
else:
if(check(alpha) and check(nums)):
print("YES")
else:
print("NO")
254A - Cards with Numbers | 215A - Bicycle Chain |
1288B - Yet Another Meme Problem | 1201C - Maximum Median |
435A - Queue on Bus Stop | 1409B - Minimum Product |
723B - Text Document Analysis | 1471C - Strange Birthday Party |
1199A - City Day | 1334A - Level Statistics |
67B - Restoration of the Permutation | 1734A - Select Three Sticks |
1734B - Bright Nice Brilliant | 357B - Flag Day |
937A - Olympiad | 1075A - The King's Race |
1734C - Removing Smallest Multiples | 1004C - Sonya and Robots |
922A - Cloning Toys | 817A - Treasure Hunt |
1136B - Nastya Is Playing Computer Games | 1388A - Captain Flint and Crew Recruitment |
592B - The Monster and the Squirrel | 1081A - Definite Game |
721C - Journey | 1400A - String Similarity |
1734E - Rectangular Congruence | 1312D - Count the Arrays |
424C - Magic Formulas | 1730C - Minimum Notation |